home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_07_07
/
v7n7056a.txt
< prev
next >
Wrap
Text File
|
1989-09-03
|
1KB
|
59 lines
Listing 3:
#include <stdio.h>
#include <stdio.h>
main(int argc, char *argv[])
{
copy_it(argv[1], argv[2]);
end_it("copy is done\n");
}
copy_it(char FileIn[55], char FileOut[55])
{
FILE *fi;
FILE *fo;
int gc;
/* The next 2 lines fixed the problem */
/* NOT VERY ELEGANT BUT IT WORKS! */
if (*FileIn == *FileOut)
end_it("ABORT: Make first letters of names different\n");
if ((fi = fopen(FileIn, "rb")) == NULL)
end_it("File not found\n");
if ((fo = fopen(FileOut, "wb")) == NULL)
{
fclose(fi);
end_it("No output\n");
}
while (!feof(fi))
{
gc = getc(fi);
if (!feof(fi))
putc(gc, fo);
}
fclose(fi);
fclose(fo);
}
/*
IF FILEIN = FILEOUT, AND FILE IS LARGER THAN ABOUT 2-3K,
6
YOU WILL DAMAGE DIRECTORY TABLE!
*/
static end_it(s)
char *s; /* String to display to User */
{
/* Display string passed and simply abort */
fprintf(stdout, s);
exit (0);
}